package com.inspur.his.controller;

import com.github.pagehelper.PageHelper;
import com.inspur.his.pojo.Fy;
import com.inspur.his.pojo.Mem;
import com.inspur.his.service.MemService;
import com.inspur.his.service.FyService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;

@Controller
    public class FyController {
        @Autowired
        FyService fyService;
    @Autowired
    MemService memService;

        @RequestMapping("fyListController")
        public String fyList(HttpServletRequest request, Model model, @RequestParam(value = "pn", defaultValue = "1") Integer pn) {
            //获取页面提交来的查询条件
            String name = request.getParameter("name");
            String memberid = request.getParameter("memberid");
            //  点击用户管理左侧菜单进行默认无条件查询
            HashMap map = new HashMap();
            map.put("name", name);
            map.put("memberid",memberid);
            PageHelper.startPage(pn, 5);
            List<Fy> fyList = fyService.fyList(map);
            PageInfo<Fy> pageInfo = new PageInfo<Fy>(fyList, fyList.size());
            model.addAttribute("fyList", fyList);
            model.addAttribute("pageInfo", pageInfo);
            model.addAttribute("name", name);
            model.addAttribute("memberid", memberid);
            return "fy/fyList.jsp";
        }
    @RequestMapping("/fyczController")
    public  String fycz(String id,Model model) {
        Mem mem = memService.getMemById(id);
        model.addAttribute("mem",mem);
        return "fy/feecz.jsp";
    }

    @RequestMapping("fyUpdateczController")
    public String fyupdatecz(Mem mem, Model model) {
        memService.updateczMem(mem);
        model.addAttribute("mem", mem);
        model.addAttribute("flag", "1");
        return "redirect:fyListController";
    }
}
